package src.base;

public class Element 
{
	public int size;
	public int time_load_balancer;
	public int time_server;
	
	public Element(int length)
	{
		this.size = length;
		this.time_load_balancer = 0;
		this.time_server = 0;
	}
	
	@Override
	public String toString()
	{
		return "Size : " + this.size + "\t| Time_LB : " + this.time_load_balancer + "\t| Time_SV : " + this.time_server;
	}
	
	public int getLength()
	{
		return this.size;
	}
	
	public int getTimeLoadBalancer()
	{
		return this.time_load_balancer;
	}
	
	public int getTimeServer()
	{
		return this.time_server;
	}
	
	public void setSize(int size) throws IllegalArgumentException
	{
		try 
		{
			if (size < 1) throw new IllegalArgumentException("Length must be > 0");
			this.size = size;
		}
		catch (IllegalArgumentException e) {
			System.err.println(e.getMessage());
		}
	}
	
	public void setTimeLoadBalancer(int time)
	{
		try 
		{
			if (time < 0) throw new IllegalArgumentException("Time load balancer must be > 0");
			this.time_load_balancer = time;
		}
		catch (IllegalArgumentException e) {
			System.err.println(e.getMessage());
		}
	}
	
	public void setTimeServer(int time)
	{
		try 
		{
			if (time < 0) throw new IllegalArgumentException("Time server must be > 0");
			this.time_server = time;
		}
		catch (IllegalArgumentException e) {
			System.err.println(e.getMessage());
		}
	}
}
